home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / smaltalk / stv.lha / STV / st_v / S7VMac10 / remov2.mth < prev    next >
Text File  |  1993-07-23  |  1KB  |  35 lines

  1. "
  2. The following method allows you to remove a class even
  3. if it has instances.  The method will report the number
  4. of detected instances (if there are any) and prompt the
  5. user for confirmation.  If the user responds positively,
  6. the method removes the instances.  It then prompts the
  7. user for confirmation of removing the class, as well.
  8.  
  9. To use this method in Smalltalk/V Mac, change the 
  10. ClassHierarchyBrowser>>menu method so the message
  11. sent when 'Remove Class' is selected is 
  12. removeClassWithConfirmation.  Do not remove the
  13. removeClass method, as this new method calls it.
  14.  
  15. Submitted by Dan Goldman, 71361,1636  June 7, 1991.
  16. For Smalltalk/V Mac only.  Please see remov1 for the
  17. Smalltalk/V PM and Smalltalk/V Windows version."
  18.  
  19. !ClassHierarchyBrowser methods !
  20.  
  21. removeClassWithConfirmation
  22.     "Private - Delete the selected class.
  23.      Notify the user first if there are instances."
  24.  
  25.      | instances |
  26.      CursorManager execute change.
  27.      instances := selectedClass allInstances size.
  28.      instances > 0 ifTrue: [
  29.         (Dialog noOrYes: instances printString,' instance(s) of this class exist.  Delete anyway?')
  30.             ifTrue: [
  31.                  selectedClass allInstances do: [:i | i become: String new].
  32.                  self removeClass]]
  33.             ifFalse: [self removeClass].
  34.      CursorManager normal change! !
  35.